home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / hurd / hurdrlimit.c < prev    next >
C/C++ Source or Header  |  1994-06-03  |  2KB  |  52 lines

  1. /* Resource limits.
  2. Copyright (C) 1994 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4.  
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Library General Public License as
  7. published by the Free Software Foundation; either version 2 of the
  8. License, or (at your option) any later version.
  9.  
  10. The GNU C Library is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13. Library General Public License for more details.
  14.  
  15. You should have received a copy of the GNU Library General Public
  16. License along with the GNU C Library; see the file COPYING.LIB.  If
  17. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  18. Cambridge, MA 02139, USA.  */
  19.  
  20. #include <hurd.h>
  21. #include <cthreads.h>
  22. #include <hurd/resource.h>
  23. #include <gnu-stabs.h>
  24.  
  25. /* This must be given an initializer, or the a.out linking rules will
  26.    not include the entire file when this symbol is referenced. */
  27. struct rlimit _hurd_rlimits[RLIM_NLIMITS] = {[0] = 0};
  28.  
  29. /* This must be initialized data for the same reason as above, but this is
  30.    intentionally initialized to a bogus value to emphasize the point that
  31.    mutex_init is still required below just in case of unexec.  */
  32. struct mutex _hurd_rlimit_lock = { SPIN_LOCK_INITIALIZER, };
  33.  
  34. static void
  35. init_rlimit (void)
  36. {
  37.   int i;
  38.  
  39.   __mutex_init (&_hurd_rlimit_lock);
  40.  
  41.   for (i = 0; i < RLIM_NLIMITS; ++i)
  42.     {
  43.       if (_hurd_rlimits[i].rlim_max == 0)
  44.     _hurd_rlimits[i].rlim_max = RLIM_INFINITY;
  45.       if (_hurd_rlimits[i].rlim_cur == 0)
  46.     _hurd_rlimits[i].rlim_cur = _hurd_rlimits[i].rlim_max;
  47.     }
  48.  
  49.   (void) &init_rlimit;
  50. }
  51. text_set_element (_hurd_preinit_hook, init_rlimit);
  52.